﻿// ==================================================
// Copyright © 2016 杭州伯庸科技 版权所有
//
// 文 件 名：SchemeManagement
// 功能描述：
//
// 创建标识：Yu.Liang(俞 亮) 2018/3/18 22:17:10
//
// 修改标识：
// 修改描述：
// ==================================================

using System.Drawing;
using System.Reflection;
using System.Windows.Forms;
using Shine.Framework;
using SuperMap.Realspace;
using SuperMap.Data;

namespace Shine.SchemaManager
{
    internal class SchemeManagement : BaseCommand
    {
        IApplication m_Application = null;
        Scene m_Scene = null;
        Workspace m_Workspace = null;
        ProjectListForm myForm = null;

        public SchemeManagement()
        {
            base.m_caption = "方案管理";
            base.m_name = "SchemaManagement";
            base.m_toolTip = "方案管理";
            base.m_message = "方案管理";
            base.m_category = "schema";
        }

        public override void OnCreate(object hook)
        {
            if(m_Application == null)
            {
                m_Application = hook as IApplication;
                m_Scene = (m_Application as IFramework).SceneControl.Scene;
                m_Workspace = m_Scene.Workspace;
            }
        }

        public override void OnClick()
        {
            //if(myForm == null || myForm.IsDisposed)
            //{
            //    myForm = ProjectListForm.GetInstance(m_Scene, m_Workspace, m_Application);
            //}
            myForm = new ProjectListForm(m_Scene, m_Workspace, m_Application);
            myForm.Show((m_Application as IFramework).MdiForm);
        }

        public override int Bitmap
        {
            get
            {
                string imgFile = Application.StartupPath + "\\Images\\" + GetType().Name + ".png";

                if (System.IO.File.Exists(imgFile) == false) return 0;

                return new Bitmap(Image.FromFile(imgFile)).GetHbitmap().ToInt32();
            }
        }

        public override bool Enabled
        {
            get { return (m_Application as IFramework).IsMapCtrlactive; }
        }
    }
}
